package com.sz.app.oss.api.system;

import com.sz.biz.app.web.BaseController;
import com.sz.common.base.dto.ResultDto;
import com.sz.common.core.system.service.SysTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by penghui.zheng <br> on 2017/8/2.
 */
@Controller
@RequestMapping("/api/v1/sys/template")
@Api(description = " ", tags = "046、pdf动态模板管理")
public class TemplateController extends BaseController {

    @Autowired
    private SysTemplateService sysTemplateService;

  
    /**
     *  获取PDF模板路径
     * @param type
     * @param owner
     * @param projectId
     * @param templateName
     * @return
     */
    @ApiOperation(value = "获取PDF模板路径", notes = "获取PDF模板路径")
    @ApiImplicitParams({@ApiImplicitParam(name = "type", value = "类型：1为贸易订单模板，2为其他自定义模板", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "owner", value = "模板所属者，type为1表示公司id，type为2表示其他业务id", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "projectId", value = "项目id，只有type等于1时才有项目",  dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "templateName", value = "模板名称",  dataType = "String", paramType = "query")})
    @RequestMapping(value = "/path", method = {RequestMethod.GET})
    public
    @ResponseBody
    ResultDto getTemplatePath(@RequestParam int type, @RequestParam int owner,
                       @RequestParam(required = false, defaultValue ="0") int projectId, @RequestParam(required = false, defaultValue = "") String templateName) {
        String path = sysTemplateService.getTemplatePath(type, owner, projectId, templateName);
        ResultDto dto = new ResultDto();
        dto.setData(path);
        return dto;
    }
}

   
